const express = require('express');
const router = express.Router();

// 获取用户列表
router.get('/', (req, res) => {
  res.json({
    users: [
      { id: 1, name: 'User 1' },
      { id: 2, name: 'User 2' }
    ]
  });
});

// 获取单个用户
router.get('/:id', (req, res) => {
  res.json({
    id: req.params.id,
    name: `User ${req.params.id}`
  });
});

// 创建用户
router.post('/', (req, res) => {
  const { name } = req.body;
  res.status(201).json({
    message: 'User created successfully',
    user: { id: Date.now(), name }
  });
});

// 更新用户
router.put('/:id', (req, res) => {
  const { name } = req.body;
  res.json({
    message: 'User updated successfully',
    user: { id: req.params.id, name }
  });
});

// 删除用户
router.delete('/:id', (req, res) => {
  res.json({
    message: `User ${req.params.id} deleted successfully`
  });
});

module.exports = router; 